home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / misc / math / libalgo.lha / algomath / src / gcd.c < prev    next >
Encoding:
Text File  |  2000-05-30  |  160 b   |  17 lines

  1. /* greatest common divisor */
  2. int am_gcd(int a,int b)
  3. {
  4.     int c;
  5.  
  6.     if(a == 0 || b == 0)
  7.         return 0;
  8.  
  9.     while(b)
  10.     {
  11.         c = a;
  12.         a = b;
  13.         b = c % b;
  14.     }
  15.  
  16.     return a;
  17. }